<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div class="father">
    <el-page-header @back="goBack" content="购买页面" class="header"></el-page-header>
    <div class="body">
      <div>
        <div class="body-item1">
          <el-image style="width: 450px" :src="url" :preview-src-list="srcList">
          </el-image>
        </div>
        <div class="body-item2">
          <div class="item2-item1">
            <div class="item1-content1">
              <h3>全景智慧旗舰SUV 问界 M9</h3>
            </div>
            <div class="item1-content2">
              <div>销售价：￥549,800</div>
              <div>
                <p> 销售数量
                  <button @click="num == 0 ? 0 : num --">-</button>
                  <button>{{ num }}</button>
                  <button @click="num++">+</button>
                </p>
              </div>
              <div class="money">所需金额：￥{{ total }}</div>
              <div class="content2-item3"><button class="item3-button" @click="pay">立即购买</button><button class="item3-button"
                  @click="addShopcart">加入购物车</button></div>
            </div>
          </div>
          <div class="item2-item2">
            <div class="item2-content1">
              <h3>商品参数</h3>
            </div>
            <div class="item2-content2">
              <p>车辆配置：问界M9 pro/鎏金黑/19英寸空气动力学轮毂/无零重力座椅/无科技舒享包</p>
              <p>享受服务：尊享至高40000元选装权益金，预计2024年4月起开始交付，如有疑问建议您咨询门店顾问。</p>
              <p>OneBox造型设计:运动肌肉轮包/高级曲面/家族化前脸/无边框设计</p>
              <p>超低风阻系数：0.203</p>
              <p>外观：霜月银/天青蓝/陶瓷白/鎏金黑/暖星云</p>
              <p>内饰：白沙杏/月影灰/雀羽红</p>
              <p>百公里加速：3.3秒</p>
              <p>最小转弯半径：5.7米</p>
              <p>传动比：13:1</p>
              <p>百公里刹停：33.5米</p>
              <p>最大侧向加速度：1G</p>
              <p>方向盘圈数：2.38圈</p>
              <p>麋鹿测试：83.1km/h</p>
              <p>快充续航：华为巨鲸800v高压电池平台/3.2C快充</p>
              <p>高阶智能驾驶：全国都能开的NCA/泊车代驾/机械车位泊车辅助</p>
              <p>星环散射体：17专业音响/7.1声道/1000W功能输出</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="hello_world">
      <button class="top" @click="toTop">
        <img src="@/assets/backToTop.png" width="100%">
      </button>
    </div>
  </div>
</template>

<script>
  import BScroll from 'better-scroll'
  export default {
    name: 'z_seven_shop',
    data() {
      return {
        num: 0,
        url: 'https://res.vmallres.com//uomcdn/CN/pms/202309/A69219E4FE787103F8F24DFB3CF22274.jpg',
        srcList: [
          'https://res.vmallres.com//uomcdn/CN/pms/202309/A69219E4FE787103F8F24DFB3CF22274.jpg'
        ]
      }
    },
    methods: {
      goBack() {
        this.$router.go(-1)
      },
      toTop() {
        window.location.reload()
      },
      sunAdd() {
        this.num = this.num + 1
      },
      sumDelete() {
        if (this.num === 0) {
          this.num = this.num - 0
        } else {
          this.num = this.num - 1
        }
      },
      addShopcart() {
        this.$store.commit('shopcart/addShopcart', {
          id: 3,
          count: parseInt(this.num),
          url: 'https://res.vmallres.com//uomcdn/CN/pms/202309/A69219E4FE787103F8F24DFB3CF22274.jpg',
          price: 549800,
          detail: '问界M9',
          selected: true,
          path: '/w_nine/shop'
        })
      },
      pay() {
        this.$router.push({
          name: 'pay',
          params: {
            detail: {
              id: 3,
              count: parseInt(this.num),
              url: 'https://res.vmallres.com//uomcdn/CN/pms/202309/A69219E4FE787103F8F24DFB3CF22274.jpg',
              price: 549800,
              detail: '问界M9',
              selected: true,
              path: '/w_nine/shop'
            }
          }
        })
        this.$store.state.onHomePage = false
      }
    },
    computed: {
      total() {
        return this.num * 549800
      }
    },
    mounted() {
      this.$nextTick(() => {
        // eslint-disable-next-line no-undef
        this.scroll = new BScroll('.body', {
          click: true,
          mouseWheel: true
        })
      })
    }
  }
</script>

<style scoped>
  .money {
    margin-bottom: 10px;
  }

  .item3-button {
    background-color: red;
    border-radius: 5px;
    margin: 3px;
    opacity: 0.8;
  }

  .item1-content2 {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .item2-content2 {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .item1-content1 {
    border-bottom: solid 1px gray;
  }

  .item2-content1 {
    border-bottom: solid 1px gray;
  }

  .item2-item2 {
    width: 440px;
    margin: 2px;
    border: solid 1px gray;
    border-radius: 5px;
    background-color: #fff;
    padding-left: 5px;
  }

  .item2-item1 {
    width: 440px;
    margin: 2px;
    border: solid 1px gray;
    border-radius: 5px;
    background-color: #fff;
    padding-left: 5px;
  }

  .top {
    position: absolute;
    width: 40px;
    height: 40px;
    bottom: 100px;
    right: 5px;
    background-color: #fff;
    border: solid 1px gray;
    border-radius: 50%;
  }

  .body-item1 {
    width: 450px;
    height: 50%;
  }

  .father {
    width: 450px;
    height: 100%;
  }

  .header {
    width: 100%;
    height: 5%;
  }

  .body {
    width: 450px;
    height: 630px;
    overflow: hidden;
    background-color: #888;
    border-bottom: solid 1px gray;
  }
</style>
